package com.zzx.boot.servlet.impl;

import com.zzx.boot.entity.table.LoginUser;
import com.zzx.boot.entity.table.User;
import com.zzx.boot.servlet.UserService;
import com.zzx.boot.utils.R;
import lombok.RequiredArgsConstructor;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

/**
 * @author tan
 * @version 1.0
 * @date 2023/7/8 21:43
 */
@Service
@RequiredArgsConstructor
public class UserDetailsServiceImpl implements UserDetailsService {

    private final UserService userService;

    @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
        User user = userService.userByUserName(username);
        LoginUser loginUser = new LoginUser();
        loginUser.setUser(user);
        //TODO
        return loginUser;
    }
}
